package Java.BlackHorse.a01CollectionsTest;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class Test4 {
    public static void main(String[] args) {
        HashMap<String, ArrayList<String>> hm = new HashMap<>();

        ArrayList<String> list1 = new ArrayList<>();
        list1.add("开封");
        list1.add("洛阳");
        list1.add("商丘");
        list1.add("安阳");

        ArrayList<String> list2 = new ArrayList<>();
        list2.add("杭州");
        list2.add("嘉兴");
        list2.add("绍兴");
        list2.add("扬州");

        ArrayList<String> list3 = new ArrayList<>();
        list3.add("深圳");
        list3.add("广州");
        list3.add("珠海");

        hm.put("河南",list1);
        hm.put("浙江",list2);
        hm.put("广东",list3);

        StringBuilder sb = new StringBuilder();
        Set<Map.Entry<String,ArrayList<String> > > entries = hm.entrySet();
        for(Map.Entry<String,ArrayList<String>> entry: entries){
             String key = entry.getKey();
             ArrayList<String> value=entry.getValue();
             sb.append(key+"=");
             for(String city:value){
                 sb.append(" "+city+" ");
             }
                sb.append("\n");
        }
        System.out.println(sb);

        System.out.println(hm);
    }
}
